package org.lds.scheduled.job.client.autoconfigure;

import org.lds.scheduled.job.admin.client.AdminClient;
import org.lds.scheduled.job.admin.client.autoconfigure.AdminClientAutoConfiguration;
import org.lds.scheduled.job.client.endpoint.ScheduledJobEndpoint;
import org.lds.scheduled.job.client.service.AbstractScheduledJobService;
import org.lds.scheduled.job.client.service.ScheduledJobService;
import org.lds.scheduled.job.client.service.impl.ScheduledJobServiceImpl;
import org.lds.scheduled.job.client.starter.RegisterJobStarter;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AutoConfigureAfter(AdminClientAutoConfiguration.class)
public class ScheduledJobClientAutoConfiguration {

    @Bean
    public RegisterJobStarter registerJobStarter(AdminClient adminClient, AbstractScheduledJobService scheduledJobService) {
        return new RegisterJobStarter(adminClient, scheduledJobService);
    }

    @Bean
    public AbstractScheduledJobService scheduledJobService() {
        return new ScheduledJobServiceImpl();
    }

    @Bean
    public ScheduledJobEndpoint scheduledJobEndpoint(ScheduledJobService scheduledJobService) {
        return new ScheduledJobEndpoint(scheduledJobService);
    }

}
